package Hot100.twoSearch;

import java.util.HashMap;
import java.util.Map;

public class findMedianSortedArrays {
    public static void main(String[] args) {

    }
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int m = nums1.length,n = nums2.length;
        int mid = 0;
        if((m + n) % 2 != 0){
            mid = (m + n) / 2;
        }
        else {
            mid = (m + n) / 2 - 1;
        }
        int count = 0;
        int point1 =0, point2 = 0;
        while (count < mid){
            if(nums1[point1] <= nums2[point2]){
                count++;
                point1++;
            }else {
                count++;
                point2++;
            }
        }
        if((m + n) % 2 != 0){
            if(nums1[point1] <= nums2[point2]){
                double ans = nums1[point1];
                return ans;
            }else {
                double ans = nums1[point2];
                return ans;
            }
        }else {
            if(nums1[point1] <= nums2[point2]){
                double ans = nums1[point1];
                return ans;
            }else {
                double ans = nums1[point2];
                return ans;
            }
        }

    }
}
